home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 1.9 KB | 69 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import quicktime.app.image.*;
-
- class ScrollingText implements Paintable {
- Font font = new Font ("Helvetica", Font.PLAIN, 30);
- Color col = Color.red;
- int y = 22;
- int oldy = 22;
- int width, height;
- Rectangle[] r = new Rectangle[2];
- boolean doFirstDraw = true;
-
- public void newSizeNotified (QTImageDrawer drawer, Dimension d) {
- width = d.width;
- height = d.height;
- doFirstDraw = true;
- }
-
- /**
- * Paint on the graphics. The supplied component is the component from which
- * the graphics object was derived or related to and is also the component
- * that is the object that paint was called upon that has called this method.
- * The Graphics object is what you should paint on.
- * This maybe an on or off screen graphics.
- * You should not cache this graphics object as it can be different
- * between different calls.
- * @param comp the component from which the Graphics object was derived or
- * related too.
- * @param g the graphics to paint on.
- */
- public Rectangle[] paint (Graphics g) {
- boolean retFull = false;
- if (doFirstDraw) {
- g.setColor (col);
- g.drawRect (0, 0, width - 1, height - 1);
- g.drawRect (1, 1, width - 3, height - 3);
- retFull = true;
- doFirstDraw = false;
- }
-
- g.clearRect (10, oldy - 20, width - 19, 36);
- g.setFont (font);
- g.setColor (col);
- g.drawString ("Scrolling Java Text", 13, y + 6);
- g.setColor (Color.blue);
- g.drawRect (10, y - 20, width - 20, 35);
-
- //redraw full image
- if (retFull) r[0] = new Rectangle(width, height);
- else {
- r[0] = new Rectangle (10, oldy - 20, width - 19, 37);
-
- // tell QTImageDrawer where we drew
- if (r[1] != null) r[1] = null;
- if (y - oldy != 1)
- r[1] = new Rectangle (10, y - 20, width - 19, 36);
- }
-
- return r;
- }
- }
-